<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">

<title>My JSP 'index.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
</head>

<body>
	<center>
		<h1>登录</h1>
		<img alt="" src="" id="img">
		<form action="login" method="post" onsubmit="return bb()">
			账号:<input type="text" name="userAccount" onblur="ckName()" /> <span
				id="msg"></span> <br /> 密码:<input type="password" name="password" /><br />

			<input type="submit" value="登录"> <a href="toAdd"><input
				type="button" value="注册">
			</a>
		</form>
	</center>

	<script type="text/javascript" src="js/jquery-1.12.4.js"></script>
	<script type="text/javascript">
		function bb() {
			var userAccount = $("[name=userAccount]").val();
			var password = $("[name=password]").val();
			if (userAccount == "" || password == "") {
				alert("请填写完整信息");
				return false;
			}
			return true;
		}
		
		function ckName() {
			var userAccount = $("[name=userAccount]").val();
			if (userAccount != null && userAccount != '') {
				$.post("cheName?userAccount=" + userAccount, function(data) {
					if (data != "false") {
						$("#msg").text("");
						$("#img").attr("src", data);
					} else {
						$("#img").attr("src", "#");
						$("#msg").text("账号不存在");
					}
				});
			}
		}
	</script>
</body>
</html>
